<?php
namespace App\Http\Controllers\Develop\Log;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\User\BillRefund;

class BillRefundController extends Controller{

    public function index(){

        return view('develop/log/billRefund');

    }

    //查询条件
    public function search(Request $request){

        $where = [];
        $bill_no = $request->input('bill_no');

        if ( ebsig_is_int($bill_no)){

            $where[] = ['bill_no',$bill_no];
        }
        $bill_data = BillRefund::where($where)
            ->orderBy($request->input('sort'),$request->input('order'))
            ->paginate($request->input('limit'))
            ->toArray();

        //返回数组
        $return = [
            'total' => $bill_data['total'],
            'rows' =>[]
        ];

        if ($bill_data['data']){
            foreach ($bill_data['data'] as $item){

                $return['rows'][] = [
                    'id' => $item['id'],
                    'bill_no' => strval($item['bill_no']),
                    'msg' => $item['msg']
                ];
            }
        }
        return response()->json($return);
    }

}